package com.dm.frontend.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.dm.common.utils.DubboUtil;
import com.dm.home.service.ItemService;

import com.dm.module.DmArea;
import com.dm.module.DmItemTypeInfo;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;
import java.util.List;

@Controller
@RequestMapping("home")
public class MianController {

    @Reference(url = DubboUtil.DUBBO_URL_HOME,version = DubboUtil.GROUP_NAME, group = DubboUtil.GROUP_NAME)
    private ItemService itemService;

    @RequestMapping("query/city/{cityId}")
    @ResponseBody
    public List<DmItemTypeInfo> queryAllCity(@PathVariable("cityId") Long cityId , HttpSession session, Model model){
        DmArea dmArea = itemService.queryAreaById(cityId);
        session.setAttribute("dmArea",dmArea);
        List<DmItemTypeInfo> city = itemService.queryCityById(cityId);
        model.addAttribute("city",city);
        return city;
    }


}
